import { createStore } from 'vuex'
// import modulesA from './modules/a'
// import modulesB from './modules/b'
import user from './modules/user'
import cart from './modules/cart'
import category from './modules/category'

import createPersistedstate from 'vuex-persistedstate'
// import { createPinia } from 'pinia'

// export const store = createPinia()
// store.use(createPiniaPersistedState({
//   key: 'erabbit'
// }))

// vue2.0 创建仓库 new vuex.store({})
export default createStore({

  state: {
    a: 10
  },
  getters: {
    newData (state) {
      return state.a + 20
    }
  },
  mutations: {
    update (state) {
      state.a = 20
    }
  },
  actions: {
    update (ctx) {
      ctx.commit('update')
    }
  },
  modules: {
    // modulesA,
    // modulesB,
    user,
    cart,
    category
  },
  plugins: [createPersistedstate({
    // 保存的key的名称
    key: 'erabbit'
    // 保存那些模块
    // paths: ['user,cart']

  })]

})
